import 'package:music_app/api/dio_client.dart';

class RealApi {
  // 获取歌曲url
  static Future<Map<String, dynamic>> getSongUrl(int id) async {
    final response = await DioUtil().get('/song/url', queryParams: {'id': id});
    if (response.statusCode == 200) {
      return response.data as Map<String, dynamic>; // 明确转换类型
    } else {
      throw Exception('Failed to load data: ${response.statusCode}');
    }
  }

  // 歌单详情
  static Future<Map<String, dynamic>> getPlayListDetail(int id) async {
    final response =
        await DioUtil().get('/playlist/detail', queryParams: {'id': id});
    if (response.statusCode == 200) {
      return response.data as Map<String, dynamic>; // 明确转换类型
    } else {
      throw Exception('Failed to load data: ${response.statusCode}');
    }
  }

  // 获取歌词
  static Future<Map<String, dynamic>> getLyric(int id) async {
    // 1468115100
    final response = await DioUtil().get('/lyric', queryParams: {'id': id});
    if (response.statusCode == 200) {
      return response.data as Map<String, dynamic>; // 明确转换类型
    } else {
      throw Exception('Failed to load data: ${response.statusCode}');
    }
  }
}
